package gjbsh.bangong.ds.service;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class MailService {
	// Spring官方提供的集成邮件服务的实现类，目前是Java后端发送邮件和集成邮件服务的主流工具。
	@Resource
	private JavaMailSender mailSender;

	// 从配置文件中注入发件人的姓名
	@Value("${spring.mail.username}")
	private String fromEmail;

	public void sendSimpleMail(String ppShoujianren, String ppSubject, String ppContent) {
		SimpleMailMessage message = new SimpleMailMessage();
		
		message.setFrom(fromEmail);
		message.setTo(ppShoujianren);	
		message.setSubject(ppSubject);
		message.setText(ppContent);
		
		mailSender.send(message);
	}
}
